home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Imposed Width.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-18  |  2.0 KB  |  81 lines  |  [TEXT/KAHL]

  1. /****************************************************************************************************
  2.     6/96 bob    Updated #includes to support changed GX Library names.
  3.     
  4.     ©1990 - 1996  Apple Computer, Inc.
  5.     All rights reserved.
  6. ****************************************************************************************************/
  7. #include <Types.h>
  8. #include <QuickDraw.h>
  9. #include <Fonts.h>
  10. #include <Windows.h>
  11. #include <Menus.h>
  12. #include <SegLoad.h>
  13. #include <Memory.h>
  14. #include <Desk.h>
  15.  
  16. #include <GXGraphics.h>
  17. #include "GraphicsLibraries.h"
  18. #include <GXEnvironment.h>
  19.  
  20. #include <GXTypes.h>
  21. #include <GXLayout.h>
  22. #include "LayoutLibrary.h"
  23.  
  24. #include "SampleInterface.h"
  25.  
  26. short MyStrLen(char *x);
  27. static short MyStrLen(x)
  28. char    *x;
  29.     {
  30.     short c = 0;
  31.     while (*x++) c++;
  32.     return c;
  33.     }    /* MyStrLen */
  34.  
  35. void ImposedWidth(WindowPtr sampleWindow)
  36.     {
  37.     /* Variables */
  38.     char        *myString = "As you wish";
  39.     gxPoint        myPoint;
  40.     gxRunControls    gxRunControls;
  41.     gxShape        layout;
  42.     short        len, level = 0, runLengths[3];
  43.     gxStyle        imposedStyle, regularStyle, styleArray[3];
  44.     gxViewPort    aViewPort;
  45.     
  46.     /* Initialization */
  47.     
  48.     myPoint.x = ff(30);
  49.     myPoint.y = ff(50);
  50.     
  51.     aViewPort = GXNewWindowViewPort(sampleWindow);
  52.     SetDefaultViewPort(aViewPort);
  53.     
  54.     len = MyStrLen(myString);
  55.     runLengths[0] = 2;
  56.     runLengths[1] = 1;
  57.     runLengths[2] = len - (runLengths[0] + runLengths[1]);
  58.     
  59.     regularStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  60.     
  61.     InitializeRunControls(&gxRunControls);
  62.     gxRunControls.flags = gxImposeWidth;
  63.     gxRunControls.imposedWidth = ff(144);
  64.     imposedStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, &gxRunControls, nil, 0, nil);
  65.     
  66.     styleArray[0] = styleArray[2] = regularStyle;
  67.     styleArray[1] = imposedStyle;
  68.  
  69.     layout = GXNewLayout(
  70.         1, &len, (void *) &myString,
  71.         3, runLengths, styleArray,
  72.         1, &len, &level,
  73.         nil, &myPoint);
  74.     GXDrawShape(layout);
  75.     
  76.     GXDisposeShape(layout);
  77.     GXDisposeStyle(regularStyle);
  78.     GXDisposeStyle(imposedStyle);
  79.     GXDisposeViewPort(aViewPort);
  80.     }    /* main */
  81.